﻿using Aspose.Cells;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using XiAnAirport.Models;

namespace XiAnAirport.BUS
{
    public class ExcelTools
    {
        public static DataTable ImportCompareMeanExcel(string strFilePath)
        {
            Workbook workbook = new Workbook(strFilePath);
            DataTable dtExcel = null;
            try
            {
                Cells cells = workbook.Worksheets[0].Cells;
                dtExcel = cells.ExportDataTableAsString(0, 0, cells.MaxDataRow + 1, cells.MaxColumn + 1, true);//showTitle
            }
            catch (Exception ex)
            {
                LogBUS logBUS = new LogBUS();
                ErrorLogInfo errorLogInfo = new ErrorLogInfo();
                errorLogInfo.operation = "导入表格";
                errorLogInfo.errorMsg = ex.ToString();
                logBUS.InsertErrorLog(errorLogInfo);
                LogHelper.Log("导入表格" + ex.ToString());
                throw new Exception(ex.Message);
            }
            return dtExcel;
        }

    }
}
